import React, { useState, useEffect } from 'react';
import { Dialog } from '@alifd/next';
import { t } from '@lingui/macro';

const ReceiptDialog = ({ dialog, onCancel }) => {
  const {
    show,
    record,
  } = dialog || {};

  const { orderId } = record?.busOrder || {};

  const { codeUrl } = global.getEnvCfg();

  const handleOnCancel = () => {
    onCancel?.();
  };

  return (
    <Dialog
      v2
      title={t`查看发票`}
      visible={show}
      width={600}
      height={750}
      onClose={() => handleOnCancel()}
      footerActions={['cancel']}
    >
      <iframe
        width={600}
        height={750}
        src={`${codeUrl}/BusSearch/invoiceInfo/${orderId}`}
      />
    </Dialog>
  );
};

export default ReceiptDialog;
